<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *留言记录
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'edit';
if($_RQ['op']=='edit'){
	$id=$merchid;
	if($id){
		$item=pdo_get('jy_51job_merch_account',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}else{
		$item=array();
	}
	$item['pcd']=$item['pcd']?json_decode($item['pcd'],true):array('city'=>'');
	$item['upass']='';
	$item['olduname']=$item['uname'];
	$return['item']=$item;
	$return['merch_type']=$this->merch_type;
	set_html('title','我的账户');
	exi($return);
}
if($_RQ['op']=='post'){
	$post=get_postdata();
	if(!$post['password'] || !$post['name']){
		exi('请填写账户名和密码','error');
	}
	if($post['name'] == $post['password']){
		exi('账号跟密码不能相同！','error');
	}
	if(!$post['password'] || !$post['password2']){
		exi('请输入密码！','error');
	}
	if($post['password'] != $post['password2']){
		exi('两次输入密码不一致！','error');
	}
	$id=intval($post['id']);
	$tablename='jy_51job_merch_account';
	if(!$post['olduname']){
		$user=pdo_get($tablename,array('uniacid'=>$_SESSION['uniacid'],'name'=>$post['name']));
		if($user['id']){
			exi('该账号已存在！','error');
		}
		$data=array(
			'name'=>trim($post['name']),
		);
	}
	$data['password']=base64_encode($post['password']);
	if($id){
		pdo_update('jy_51job_merch_account',$data,array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}else{
		$data['status']=1;
		$data['uniacid']=$_SESSION['uniacid'];
		$data['createtime']=time();
		pdo_insert('jy_51job_merch_account',$data);
	}
	exi('操作成功！','','/merch.index/');
}
